package cn.itrip.controller;

import cn.itrip.beans.dto.Dto;
import cn.itrip.beans.vo.hotel.SearchHotelVO;
import cn.itrip.common.DtoUtil;
import cn.itrip.common.Page;
import cn.itrip.service.HotelService;
import cn.itrip.vo.ItripHotelVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author jie
 * @date 2019/5/7 -11:26
 */
@Controller
public class HotelController {
    @Resource
    private HotelService hotelService;

    @ApiOperation(value = "分页查询酒店",produces = "application/json",httpMethod = "post")
    @ResponseBody
    @RequestMapping(value = "queryPage",method = RequestMethod.POST)
    public Dto queryPage (@RequestBody SearchHotelVO vo) throws Exception{
        Page<ItripHotelVo> page = hotelService.queryPage(vo, vo.getPageNo(), vo.getPageSize());

        return DtoUtil.returnDataSuccess(page);
    }

    @ApiOperation(value = "城市id查询",produces = "application/json",httpMethod = "post")
    @ResponseBody
    @RequestMapping(value = "queryByCityID",method = RequestMethod.POST)
    public Dto queryByCityID(@RequestParam int cityId,
                             @RequestParam int pageNo,
                             @RequestParam int pageSize) throws Exception{
        Page<ItripHotelVo> page = hotelService.queryByCityId(cityId, pageNo, pageSize);
        return DtoUtil.returnDataSuccess(page);
    }
}
